habari: convert url to link

by

in

The only feature I was missing in habari was tha automatic conversion of urls to clickable links. I googled and found the following code snippet: http://codesnippets.joyent.com/posts/show/2104. To use this in your habari theme, insert the following into your theme.php:

	public function filter_comment_content_out($content){
	$pattern = "@\b(https?://)?(([0-9a-zA-Z_!~*'().&=+$%-]+:)?[0-9a-zA-Z_!~*'().&=+$%-]+\@)?(([0-9]{1,3}\.){3}[0-9]{1,3}|([0-9a-zA-Z_!~*'()-]+\.)*([0-9a-zA-Z][0-9a-zA-Z-]{0,61})?[0-9a-zA-Z]\.[a-zA-Z]{2,6})(:[0-9]{1,4})?((/[0-9a-zA-Z_!~*'().;?:\@&=+$,%#-]+)*/?)@";
	return preg_replace($pattern, '\0', $content);
	 }

After this is done all the urls typed in the commentbox will be displayed as clickable links.


Comments

2 responses to “habari: convert url to link”

  1. Galamb Avatar
    Galamb

    google.css-be mintha hiányozna a pre.prettyprint -hez egy overflow: auto, mert így egy pöppet csúnya 😛

  2. Jogos. Majd beteszem, aztán megírom a nagy plugin kezelőnek. Köszönöm. Sajnos az utóbbi időben nem sok idő jutott a blogra.